with Ada.Calendar; use Ada.Calendar;
with Ada.Finalization;
package Legend.Timers is

   World_Clock_Interval : constant Duration := 1.0 / 48.0;

   -- 定时事件将投递到SDL的事件队列
   -- SDL事件处理例程需响应User_Event_Code_Timer事件
   task World_Clock is

      entry Start;

      entry Stop;

      -- 创建定时器(Repeat为0表示无限重复, 否则为重复次数)
      entry Add_Timer (
         Interval : Duration; 
         Repeat   : Natural; 
         At_Time  : Duration := 0.0;
         Id       : out Hash_Type
         );

      -- 修改定时器
      entry Modify_Timer (
         Id       : Hash_Type;
         Interval : Duration; 
         Repeat   : Natural 
         );

      -- 删除定时器
      entry Delete_Timer (Id : Hash_Type);
   end World_Clock;

private

   type Timer_Type is record
      Interval        : Duration;  -- 定时间隔
      Repeat          : Natural;   -- 重复次数
      Remain_Interval : Duration;  -- 剩余定时间隔
      Remain_Repeat   : Natural;   -- 剩余重复次数
      Trigger_Count   : Natural;   -- 触发次数
   end record;

end Legend.Timers;
